package love.yuanmengrobot.thousandlanguagegarden.bus.service.impl;

import love.yuanmengrobot.thousandlanguagegarden.bus.entity.BookEvent;
import love.yuanmengrobot.thousandlanguagegarden.bus.dao.BookEventDao;
import love.yuanmengrobot.thousandlanguagegarden.bus.service.BookEventService;
import love.yuanmengrobot.zframe.ioc.annotation.Resource;


import java.util.List;

/**
 * 书籍事件(BookEvent)表服务实现类
 *
 * @author makejava
 * @since 2021-07-13 14:28:12
 */

public class BookEventServiceImpl implements BookEventService {
    @Resource
     BookEventDao bookEventDao;

    /**
     * 通过ID查询单条数据
     *
     * @param objectid 主键
     * @return 实例对象
     */
    @Override
    public BookEvent queryById(String objectid) {
        return this.bookEventDao.queryById(objectid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<BookEvent> queryAllByLimit(int offset, int limit) {
        return this.bookEventDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param bookEvent 实例对象
     * @return 实例对象
     */
    @Override
    public BookEvent insert(BookEvent bookEvent) {
        this.bookEventDao.insert(bookEvent);
        return bookEvent;
    }

    /**
     * 修改数据
     *
     * @param bookEvent 实例对象
     * @return 实例对象
     */
    @Override
    public BookEvent update(BookEvent bookEvent) {
        this.bookEventDao.update(bookEvent);
        return this.queryById(bookEvent.getObjectid());
    }

    /**
     * 通过主键删除数据
     *
     * @param objectid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String objectid) {
        return this.bookEventDao.deleteById(objectid) > 0;
    }
}
